// src/routes/categoryRoutes.ts
import express from 'express';
import {
    addCategory,
    getAllCategories,
    getCategoryById,
    updateCategory,
    deleteCategory
} from '../controllers/categoryController';
import { tokenVerification } from '../middlewares/tokenVerification';
// 强制将 tokenVerification 转换为 RequestHandler 类型
import { RequestHandler } from 'express';

const router = express.Router();

// 添加新分类
router.post('/', tokenVerification as RequestHandler, addCategory);

// 查询所有分类
router.get('/', tokenVerification as RequestHandler, getAllCategories);

// 查询单个分类详情
router.get('/:family_id', tokenVerification as RequestHandler, getCategoryById);

// // 修改分类
router.post('/updateCategory', tokenVerification as RequestHandler, updateCategory);

// 删除分类 
router.post('/deleteCategory', tokenVerification as RequestHandler, deleteCategory)

export default router;
